<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2022/1/18
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common/head.jsp"%>
<html>
<head>
    <title>添加课程信息</title>
    <script src="../static/js/jquery-3.4.1.js"></script>
    <script>
        $(function(){
            $.ajax({
                url:"../user/lookcourse",
                data:{courseid:${courseid}},
                type:"post",
                dataType:"json",
                success:function(data) {
                    // alert(data.coursename)
                    var str = "";
                    str += "<tr><td>课程号：</td><td><input type='text' readonly name='courseid' value='" + data.courseid + "'> </td></tr>" +
                        "   <tr>  <td>课程名称：</td><td><input readonly type='text' name='coursename' value='" + data.coursename + "'></td></tr>" +
                        "   <tr>  <td>班级名称：</td><td><input readonly type='text' name='clazz' value='" + data.clazz + "'></td></tr>" +
                        "   <tr>  <td>任课老师：</td><td>" +
                        "<input type='text' name='tname' value='" + data.tname + "'>" +
                        "</td>" +
                        "</tr>" +
                        " <tr><td colspan='2'>" +
                        "                <div align='center'>" +
                        "                <input type='submit'  value='修改'>" +
                        "                <input type='reset' value='重置'>" +
                        "                </div>" +
                        "            </td></tr>"
                    $(".addcourse").append(str);
                }
            })
        })
        function update3(){
            var course = $("#updatecourse").serializeArray();
            alert(course)
            $.ajax({
                url:"../user/updatecourse",
                data:course,
                type:"get",
                dataType:"json",
                success:function(data) {
                    alert(data)
                    if(data== true){
                        alert("修改成功");
                        location.href="page/course"
                    }else {
                        alert("修改失败");
                        location.href="page/updatecourse?courseid="+${courseid};
                    }
                }
            })
            return false;
        }
    </script>
</head>
<style>
    form,table{
        margin-left: auto;
        margin-right: auto;
        margin-top: 100px;
    }
    td{
        width: 200px;
        height: 20px;
        text-align: center;

    }
</style>
<body>
<%--240,248,255--%>
<form onsubmit="return update3()" id="updatecourse" name="updatecourse">
    <table class="addcourse" style="background-color: #f0f8ff;" border="1px solid red" cellspacing="0px"  >
        <caption><h2>修改课程信息</h2></caption>
<%--        <tr>--%>
<%--            <td>课程编号：</td>--%>
<%--            <td>--%>
<%--                <input readonly  type='text' id='courseid' name='courseid' value="" >--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <tr>--%>
<%--            <td>课程名：</td>--%>
<%--            <td>--%>
<%--                <input readonly  type='text' id='coursename' name='coursename' >--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <tr>--%>
<%--            <td>班级：</td>--%>
<%--            <td>--%>
<%--                <input readonly  type='text' id='clazz' name='clazz' >--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <tr>--%>
<%--            <td>教师：</td>--%>
<%--            <td>--%>
<%--                <input required type='text' id='tname' name='tname' >--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <tr><td colspan='2'>--%>
<%--            <div align='center'>" +--%>
<%--                <input type='submit'  value='修改'>--%>
<%--                <input type='reset' value='重置'>--%>
<%--            </div>--%>
<%--        </td>--%>
<%--        </tr>--%>
    </table>
</form>
<%@include file="common/foot.jsp" %>
</body>
</html>
